package edu.xust.MetadataGenerator.service;

import java.util.List;

import edu.xust.MetadataGenerator.domain.Field;

public interface FieldParser {
	public final static String DT_DECIMAL = "Decimal";
	public final static String DT_TEXT = "Text";
	public final static String DT_DATE = "Date";
	public final static String DT_UNDEFINED = "Undefined";
	public final static String DT_DECIMAL_ZH = "数值";
	public final static String DT_TEXT_ZH = "文本";
	public final static String DT_DATE_ZH = "日期";
	public final static String DT_UNDEFINED_ZH = "未定义";
	
	public enum DataType{
		Decimal(DT_DECIMAL), Text(DT_TEXT), Date(DT_DATE), Undefined("Undefined");
		
		private final String _dataType;
		
		private DataType(String dataType){
			_dataType = dataType;
		}
		
		@Override
		public String toString() {
			return _dataType;
		}
		
		public static String zh2En(String dataTypeZh){
			if(dataTypeZh.equals(DT_DECIMAL_ZH)){
				return DT_DECIMAL;
			}else if(dataTypeZh.equals(DT_TEXT_ZH)){
				return DT_TEXT;
			}else if(dataTypeZh.equals(DT_DATE_ZH)){
				return DT_DATE;
			}
			return DT_DECIMAL;
		}
		
		public static String toType(String dataTypeZh){
			if(dataTypeZh.equals(DT_DECIMAL_ZH)){
				return "int";
			}else if(dataTypeZh.equals(DT_TEXT_ZH)){
				return "varchar(50)";
			}else if(dataTypeZh.equals(DT_DATE_ZH)){
				return "date";
			}
			return "int";
		}
		
		public String toStringEn(){
			return zh2En(_dataType);
		}
	}

	public List<Field> load(String fileName);
	public List<Field> load(String fileName, String delemiter);
}
